package ClassPackage;


import java.io.Serializable;
import java.util.HashSet;
import java.util.Set;
import javax.persistence.Id;
import org.hibernate.Session;
import org.hibernate.SessionFactory;

import org.hibernate.annotations.Entity;


/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/**
 *
 * @author Pipaillon
 */
@Entity
public class Utilisateur implements Serializable{

    @Id
    private int ID;

    private String name;
    private String lastname;
    private String login;
    private String password;

    private int nbjetons;

    private Set<Film> film_vu = new HashSet<Film>();
    private Set<Film> film_a_voir= new HashSet<Film>();

   public Utilisateur()
    {
        
    }
    public Utilisateur (String nom, String prenom, String log, String passwrd)
    {
        name = nom;
        lastname = prenom;
        login=log;
        password= passwrd;

        nbjetons=0;
    }

    

    public Utilisateur getUser(SessionFactory cfg,int id)
    {
        Session hibernate = cfg.getCurrentSession();
        hibernate.getTransaction().begin();
        return (Utilisateur)hibernate.get(Utilisateur.class,id);
    }

    /**
     * @return the ID
     */
    public int getID() {
        return ID;
    }

    /**
     * @param ID the ID to set
     */
    public void setID(int ID) {
        this.ID = ID;
    }

    /**
     * @return the name
     */
    public String getName() {
        return name;
    }

    /**
     * @param name the name to set
     */
    public void setName(String name) {
        this.name = name;
    }

    /**
     * @return the lastname
     */
    public String getLastname() {
        return lastname;
    }

    /**
     * @param lastname the lastname to set
     */
    public void setLastname(String lastname) {
        this.lastname = lastname;
    }

    /**
     * @return the login
     */
    public String getLogin() {
        return login;
    }

    /**
     * @param login the login to set
     */
    public void setLogin(String login) {
        this.login = login;
    }

    /**
     * @return the password
     */
    public String getPassword() {
        return password;
    }

    /**
     * @param password the password to set
     */
    public void setPassword(String password) {
        this.password = password;
    }

    /**
     * @return the nbjetons
     */
    public int getNbjetons() {
        return nbjetons;
    }

    /**
     * @param nbjetons the nbjetons to set
     */
    public void setNbjetons(int nbjetons) {
        this.nbjetons = nbjetons;
    }

    /**
     * @return the film_vu
     */
    public Set<Film> getFilm_vu() {
        return film_vu;
    }

    /**
     * @param film_vu the film_vu to set
     */
    public void setFilm_vu(Set<Film> film_vu) {
        this.film_vu.addAll(film_vu);
    }

    /**
     * @return the film_a_voir
     */
    public Set<Film> getFilm_a_voir() {
        return film_a_voir;
    }

    /**
     * @param film_a_voir the film_a_voir to set
     */
    public void setFilm_a_voir(Set<Film> film_a_voir) {
        this.film_a_voir.addAll(film_a_voir);
    }
    
}

  